<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>

<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
        <meta name="format-detection" content="telephone=no,email=no,adress=no" />
        <META HTTP-EQUIV="luxiaoqing" CONTENT="no-cache">

        <title>69圈城-商家</title>
        
        <jsp:include page="../lbi/merCommon.jsp"></jsp:include>
    </head>

    <body>
        <!--头部-->
        <div class="business_top">
            <jsp:include page="../lbi/merHead.jsp"></jsp:include>

            <div class="clear"></div>
        </div>
        <!--头部end-->

        <div class="clear4"></div>

        <input type="hidden" id="shopId" value="${shopId }">

        <!--中间-->
        <div class="individual_form-center">
            <!--左边导航部分-->
            <jsp:include page="../lbi/merLeft.jsp"></jsp:include>
            <!--左边导航部分end-->

            <!--右边详情部分-->
            <div class="individual_form-center-right">
                <!--所在位置-->
                <div class="individual_form-center-right-position">
                    <span class="span01">系统设置</span>

                    <span class="span01">></span>

                    <span class="span01">修改手机号</span>
                </div>
                <!--所在位置end-->

                <div class="clear"></div>

                <div class="individual_form-center-right-details">
                    <div class="individual-form-set_phone">
                            <div class="individual-form-set_phone-form">
                                <div class="clear3"></div>

                                <div class="individual-form-set_phone-form-demo">
                                    <div class="individual-form-set_phone-form-demo-span">
                                        新手机号码
                                    </div>

                                    <div class="individual-form-set_phone-form-demo-input">
                                        <input type="text" id="userName" name='new_phone' maxlength="11" required />
                                    </div>
                                    <div id="error1">
                                        
                                    </div>

                                    <div class="individual-form-set_phone-form-demo-yzm">
                                        <input type="button" id="btn" value="发送验证码" />
                                    </div>

                                    <div class="clear"></div>
                                </div>

                                <div class="clear3"></div>

                                <div class="individual-form-set_phone-form-demo">
                                    <div class="individual-form-set_phone-form-demo-span">
                                        输入验证码
                                    </div>

                                    <div class="individual-form-set_phone-form-demo-input">
                                        <input type="text" id="phone_code" name='phone_code' required />
                                    </div>

                                    <div class="clear"></div>
                                </div>

                                <div class="clear3"></div>


                                <div class="clear3"></div>

                                <div class="individual-form-set_phone-form-sub">
                                    <input type="button" value="提&nbsp;&nbsp;&nbsp;&nbsp;交" onclick="updateMobile()" />
                                </div>

                                <div class="clear3"></div>

                               <!--  <div class="individual-form-set_phone-form-span">
                                    注：1.本公司承诺不会对外泄露您的手机号码及用于其他任何商业用途。<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2.某某某。
                                </div> -->
                            </div>
                    </div>

                    <div class="clear"></div>
                    
                </div>
            </div>
            <!--右边详情部分end-->

            <div class="clear2"></div>
        </div>
        <!--中间end-->

        <div class="clear2"></div>

        <!--底部-->
        <div class="business_foot">
            <jsp:include page="../lbi/merFooter.jsp"></jsp:include>
        </div>
        <!--底部end-->

        <div class="clear8"></div>
<script type="text/javascript" src="<c:url value="/js/jquery.validate.min.js"/>"></script>
<!--查看显示end-->
<script src="<c:url value="/js/jquery.validate.min.js"/>" type="text/javascript"></script>
<!--验证码倒计时-->

<script type="text/javascript">

$("#number").addClass("individual_form-center-left-nav-demo-02_dj");

var _serviceURL='/69mark/merchant';//必须设置

$('#btn').click(function(){
    
    var btn = $(this);
    btn.attr("disabled", "disabled").addClass("dis");
    var time = 60000;
    var time2 = setInterval(function() {
        time -= 1000;
        if ((time / 1000) == 0) {
            btn.val("重新发送");
            window.clearInterval(time2);
            btn.removeAttr("disabled").removeClass("dis");
        }
        else {
            btn.val("重新发送(" + time / 1000 + ")");
        }

    }, 1000);
    
   var url = _serviceURL+"/toSmsSendPws.do";
    var regPhone = /^1([3578]\d|4[57])\d{8}$/;
    var shopId = $("#shopId").val();
    var userName = $("#userName").val();
    if (userName !=null &&  regPhone.test( userName )) {
        $.post(url,{'userName':userName,'shopId':shopId},function(data){
            if (data == "1") {
            }else if (data == "2") {
                alert('该账号不存在');
                btn.val("重新发送");
                window.clearInterval(time2);
                btn.removeAttr("disabled").removeClass("dis");
            }else{
                alert('短信发送失败。');
                btn.val("重新发送");
                window.clearInterval(time2);
                btn.removeAttr("disabled").removeClass("dis");
            }
        })
    }else {
        alert("填写正确手机号");
        btn.val("重新发送");
        window.clearInterval(time2);
        btn.removeAttr("disabled").removeClass("dis");
    }
})

function updateMobile(){
    var userName = $("#userName").val();
    var phone_code = $("#phone_code").val();
    var shopId = $("#shopId").val();
    
    $.ajax({
          type : "POST",
            url : _serviceURL+"/updateMobile.do",
            cache : false,
            data : "userName="+userName+"&phone_code="+phone_code+"&shopId="+shopId,
            dataType : 'json',
            success : function(data) {
                if (data == 1) {
                	alert("修改成功");
                	
                	$("#userName").val("");
                	$("#phone_code").val("");
                	
                }else if (data == 2) {
                	alert("手机号已存在");
                }else{
                    alert('验证码错误');
                }
            }
      })
    
}

</script>
    </body>

</html>